Other

# A tibble: 6 × 4
  anxiety flexibility mindfulness activity
    <dbl>       <dbl> <chr>       <chr>   
1    50.2        44.4 no          pilates 
2    31.5        47.7 yes         altro   
3    34.0        65.6 no          pilates 
4    37.1        50.7 no          altro   
5    48.3        51.3 no          altro   
6    16.9        67.2 yes         altro   
see this specific code
head(data)
# A tibble: 6 × 4
  anxiety flexibility mindfulness activity
    <dbl>       <dbl> <chr>       <chr>   
1    50.2        44.4 no          pilates 
2    31.5        47.7 yes         altro   
3    34.0        65.6 no          pilates 
4    37.1        50.7 no          altro   
5    48.3        51.3 no          altro   
6    16.9        67.2 yes         altro   
see this specific code
```{r}
#| code-fold: true
#| code-summary: see this specific code
head(data)
```
# A tibble: 6 × 4
  anxiety flexibility mindfulness activity
    <dbl>       <dbl> <chr>       <chr>   
1    50.2        44.4 no          pilates 
2    31.5        47.7 yes         altro   
3    34.0        65.6 no          pilates 
4    37.1        50.7 no          altro   
5    48.3        51.3 no          altro   
6    16.9        67.2 yes         altro   
see this specific code
```{r}
#| code-fold: true
#| code-summary: see this specific code
str(data)
```
spc_tbl_ [300 × 4] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ anxiety    : num [1:300] 50.2 31.5 34 37.1 48.3 ...
 $ flexibility: num [1:300] 44.4 47.7 65.6 50.7 51.3 ...
 $ mindfulness: chr [1:300] "no" "yes" "no" "no" ...
 $ activity   : chr [1:300] "pilates" "altro" "pilates" "altro" ...
 - attr(*, "spec")=
  .. cols(
  ..   anxiety = col_double(),
  ..   flexibility = col_double(),
  ..   mindfulness = col_character(),
  ..   activity = col_character()
  .. )
 - attr(*, "problems")=<externalptr> 
see this specific code
summary(data)
    anxiety        flexibility    mindfulness          activity        
 Min.   : 1.483   Min.   :26.91   Length:300         Length:300        
 1st Qu.:25.977   1st Qu.:44.24   Class :character   Class :character  
 Median :33.922   Median :49.56   Mode  :character   Mode  :character  
 Mean   :33.418   Mean   :50.34                                        
 3rd Qu.:41.974   3rd Qu.:56.32                                        
 Max.   :64.775   Max.   :82.41                                        
see this specific code
```{r}
#| code-fold: true
#| code-summary: see this specific code
summary(data)
```
    anxiety        flexibility    mindfulness          activity        
 Min.   : 1.483   Min.   :26.91   Length:300         Length:300        
 1st Qu.:25.977   1st Qu.:44.24   Class :character   Class :character  
 Median :33.922   Median :49.56   Mode  :character   Mode  :character  
 Mean   :33.418   Mean   :50.34                                        
 3rd Qu.:41.974   3rd Qu.:56.32                                        
 Max.   :64.775   Max.   :82.41                                        

Table of the data for anxiety and flexibility

Table 1 illustrates the characteristics of the population of interest

knitr::kable(head(data))
Table 1: Characteristics of population
anxiety flexibility mindfulness activity
50.17244 44.39524 no pilates
31.47451 47.69823 yes altro
34.03981 65.58708 no pilates
37.06712 50.70508 no altro
48.30549 51.29288 no altro
16.94087 67.15065 yes altro

?@lst-table1 illustrates a basic use of the kable() function

Correlation between anxiety and flexibility stratified based on mindfulness

?@lst-plot1 illustrates a basic use of the function plot()

see this specific code
ggplot(data,
       aes(x=flexibility, y=anxiety, color=mindfulness)) +
  geom_point()

Figure 1: Correlation between anxiety and flexibility stratified based on mindfulness

Figure and table

ggplot(mtcars, 
       aes(hp, mpg, color = factor(am))) +
  geom_point() +
  geom_smooth(formula = y ~ x, method = "loess") +
  theme(legend.position = 'bottom')

datatable(mtcars,
  options = list(pageLength = 5))
knitr::kable(head(mtcars))
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
ggplot(mtcars, 
       aes(hp, mpg, color = factor(am))) +
  geom_point() +
  geom_smooth(formula = y ~ x, method = "loess") +
  theme(legend.position = 'bottom')

Multiple plots Figure 2 illustrates different things. Figure 2 (a) illustrates the correlation between anxiety and flexibility, Figure 2 (b) illustrates the polynomial regression model, Figure 2 (c) the Linear regression model, Figure 2 (d) the GLM with Poisson

(a) The data

(b) Polynomial

(c) Linear Model

(d) GLM with Poisson

Figure 2: One dataset, different models

Table 2 presents two datasets: Table 2 (a) is cars and Table 2 (b) is pressure

Table 2: Datasets

(a) Cars
speed dist
4 2
4 10
7 4
7 22
8 16
9 10
(b) Pressure
temperature pressure
0 0.0002
20 0.0012
40 0.0060
60 0.0300
80 0.0900
100 0.2700

#Annotation

mtcars %>%
  ggplot( aes(mpg, hp, size = gear)) +
  geom_point() +
  geom_smooth(method = "lm")
1
This does that
2
This other thing is this
3
And look at this!
4
Please have mercy
`geom_smooth()` using formula = 'y ~ x'

The mean of the gear variable in mtcars is mean(mtcars$gear)

The mean of the gear variable in mtcars is 3.6875